<?php
class PublicRouter
{
	protected $_requestUri;
	protected $_parsedUri;
	public function __construct($requestUri)
	{
		/*$lenght = strlen($requestUri)-1;
		if(substr($requestUri, 0, 1) == "/")
		{
			 
			$requestUri = substr($requestUri, 1, $lenght);
			$lenght = strlen($requestUri);
		}
		if(substr($requestUri,$lenght-1, 1) == "/")
		{
			$requestUri = substr($requestUri, 0, $lenght-1);
		} */
		$this->_requestUri = $requestUri;
		$this->parseUri($requestUri);	
	}
	
	protected function parseUri($requestUri)
	{
		$parsedUri = explode("/", $requestUri);
		for($i=0;$i<count($parsedUri); $i++)
		{
			if(empty($parsedUri[$i]))
			{
				unset ($parsedUri[$i]);
			}
		}
	 	$count = count($parsedUri);//(count($parsedUri)>0)? count($parsedUri)-1: count($parsedUri);
		$parsedUri[$count] = preg_replace('#(\.html)#', '', $parsedUri[$count]);
		return $this->_parsedUri = $parsedUri;
	}
	public function getRequestedUri()
	{
		return $this->_requestUri;
	}
	
	public function getParsedUri()
	{
		return $this->_parsedUri;
	}
}
?>